<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>分销推荐</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <style>
        body{
            width: 100vw;
            height: 100vh;
            padding: 0;
            margin: 0;
            background: url(img/share_bg.png)center no-repeat;
            background-size: 100% 100%;
            overflow:hidden;
        }
        canvas{
            display:none;
        }
        body>img{
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
            height:100%;
            z-index: 1000;
        }

        .share_bg  img.bgc{
            width: 100%;
            height: 100%;
        }
        .ewm{
            position: absolute;
            left:50%;
            top:64%;
            transform: translate(-50%,50%);
            -moz-transform: translate(-50%,-50%);
            -o-transform: translate(-50%,-50%);
            -webkit-transform: translate(-50%,-50%);
            bottom:1rem;
            z-index: 1000;
            width: 4.75rem;
            height: 4.75rem;
        }
        .ewm img{
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body class="share_bg" id="box">
<div>
    <div class="ewm" id="boss">
        <img src="img/ewm.png" class="" alt="">
    </div>
</div>
<input class="example" type="button" value="button" hidden>
</body>
<script src="js/jquery.min.js"></script>
<script src="js/font-size.js"></script>
<script src="js/html2canvas-5.js?v=1.2" type="text/javascript" charset="utf-8"></script>
</html>

<script type="text/javascript">
    $(document).ready(function () {

        setTimeout(function () {
            $(".example").click();
        },100);
        $(".example").on("click", function (event) {
            event.preventDefault();
            var ewm=document.getElementById('boss');
            var center=document.getElementsByTagName("body")[0];
            html2canvas(center, {
                taintTest: true,
                useCORS: true,
                letterRendering: true,
                onrendered: function (canvas) {
                    canvas.id = "mycanvas";
                    center.appendChild(canvas);
                    //生成base64图片数据
                    var dataUrl = canvas.toDataURL();  console.log(dataUrl);
                    var newImg = document.createElement('img');
                    newImg.src = dataUrl;
                    document.body.appendChild(newImg);
                }
            });
        });
    })
</script>